package com.itcast.donkey.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;

import com.itcast.donkey.R;

/**
 * Created by lanouhn on 16/8/23.
 */
public class SplashActivity extends AppCompatActivity {
    private ImageView iv_spash;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        initView();

    }

    private void initView() {
        iv_spash = (ImageView) findViewById(R.id.iv_splash);
        //0代表不显示，1代表显示
        AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
        alphaAnimation.setDuration(5000);// 设置动画持续时长
        alphaAnimation.setFillAfter(true);
        alphaAnimation.setRepeatCount(0);
        alphaAnimation.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                // TODO Auto-generated method stub
                // 在动画结束的时候做操作
                Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                startActivity(intent);
                finish();

            }
        });
        iv_spash.startAnimation(alphaAnimation);
    }
}
